package com.weavernorth.retailExperienceAward;

import com.weavernorth.util.Logger4jUtil;
import com.weavernorth.util.dateUtils;
import org.apache.log4j.Logger;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.interfaces.schedule.BaseCronJob;
/**
 * @Author: bruseewang
 * @Package: com.weavernorth.retailExperienceAward.ZddpfstjSummaryTimmer
 * @date: 2020/6/4 16:01
 * @description: 终端店铺分数统计总得分计算
 */
public class ZddpfstjSummaryTimmer  extends BaseCronJob {
    public String cycle;
    public String getcycle() {
        return cycle;
    }
    public void setcycle(String cycle) {
        this.cycle = cycle;
    }
    @Override
    public void execute() {
        Logger log =Logger4jUtil.getLoggerByName("/Timmer/ZddpfstjSummaryTimmer/");
        log.info("终端店铺分数统计总得分计算接口执行开始----：");
        RecordSet rs = new RecordSet();
        RecordSet rs_update=new RecordSet();
        String strKhzq= dateUtils.previousMonth(0);//当前年月所对应的周期
        if (cycle!=null){
            strKhzq=dateUtils.previousMonth(Integer.parseInt(cycle));
        }
        log.info("考核周期为："+strKhzq);
        String strSql="select * from uf_zddpfstj where khzq='"+strKhzq+"' AND fwbz40 is not null AND clbz20 is not null AND crm5 is not NULL AND yybz35 is not null and dpzt != 2";
        rs.execute(strSql);
        while (rs.next()){
            //id
            String strId = Util.null2String(rs.getString("id"));
            //店铺状态
            String strDpzt = Util.null2String(rs.getString("dpzt"));
            //获取服务标准评分
            Double db_Fwbz = Util.getDoubleValue(rs.getString("fwbz40"), 0.00);
            //获取陈列管理
            Double db_Clgl = Util.getDoubleValue(rs.getString("clbz20"), 0.00);
            //获取CRM评分
            Double db_CRM =  Util.getDoubleValue(rs.getString("crm5"), 0.00);
            //获取零售运营评分
            Double db_Lsyy = Util.getDoubleValue(rs.getString("yybz35"), 0.00);

            //region[添加hr评分 add by wangwenbin at 20220214]
            //获取HR评分
            Double db_hr = Util.getDoubleValue(rs.getString("hr10"), 0.00);
            //endregion

            Double db_zdf=db_Fwbz+db_Clgl+db_CRM+db_Lsyy+db_hr;
            log.info("总得分："+db_zdf);
            //不计算店铺状态为2(闭店)的总得分
            if (!"".equals(strDpzt)||!"2".equals(strDpzt)) {
                String strUpdateSql = "update uf_zddpfstj set zdf=" + db_zdf + " where id='" + strId + "'";
                rs_update.execute(strUpdateSql);
            }
        }
        log.info("终端店铺分数统计总得分计算接口执行结束----：");

    }
}
